<template name="gateway">
	<view>
		<scroll-view :scroll-y="modalName==null" class="page" :class="modalName!=null?'show':''">
			<cu-custom bgColor="bg-gradual-pink" :isBack="true">
				<block slot="content">隐患分析</block>
			</cu-custom>
			<view class="disflex">
				<view class="searchtip">
					<uni-search-bar placeholder="请输入隐患描述" @confirm="search" v-model="dangerDesc">
					</uni-search-bar>
				</view>
				<view class="span">
					<analysisdrawer :type="typelei" ref="mainindex" @testShow="getlist"></analysisdrawer>
				</view>

			</view>
			<view class="list">
				<view class="h-table">
					<view class="h-tr h-tr-3 h-thead">
						<view class="h-td">序号</view>
						<view class="h-td fontBold">隐患描述</view>
						<view class="h-td">隐患数</view>
						<view class="h-td">已整改</view>
						<view class="h-td">未整改</view>
					</view>
					<view class="h-tr h-tr-3" v-if="index < 1" v-for="(item,index) in formDataList" :key="index + '1'">
						<view class="h-td"></view>
						<view class="h-td fontBold">{{item.text}}</view>
						<view class="h-td">{{item.dangerNum}}</view>
						<view class="h-td">{{item.noRectifyNum}}</view>
						<view class="h-td">{{item.rectifyNum}}</view>
					</view>
					<view class="h-tr h-tr-3" v-if="index >= 1" v-for="(item,index) in formDataList" :key="index">
						<view class="h-td">{{index}}</view>
						<view class="h-td fontBold" @click="compCheck(item.id,'')">{{item.text}}</view>
						<view class="h-td" @click="compCheck(item.id,'')">{{item.dangerNum}}</view>
						<view class="h-td" @click="compCheck(item.id,'0')">{{item.noRectifyNum}}</view>
						<view class="h-td" @click="compCheck(item.id,'1')">{{item.rectifyNum}}</view>
					</view>
				</view>
			</view>
			<!-- 弹框 -->
			<uni-popup ref="bottompopup" type="bottom" :mask-click="true">
				<view class="scortop">
					<view class="title">隐患清单</view>
					<uni-icons type="close" size="30" @click="compclose"></uni-icons>
				</view>
				<view class="scrollbox">
					<view class="box">
						<view class="formbox">
							<view class="positop">
								<uni-search-bar v-model="searchDesc" @confirm="search" @input="input"></uni-search-bar>
								<!-- <view class="h4">高层公共建筑未明确消防安全经理人</view> -->
							</view>
							<scroll-view @scrolltolower="lowerBottom" @refresherrefresh="getFresh" scroll-y="true"
								class="scrollHeight">
								<uni-forms ref="form">
									<view class="ul border" v-for="(item,index) in dangerList" :key="index"
										@click="gotoDetail(item.dangerId,item.placeId)">
										<view class="c1 bootm">{{item.placeName}}</view>
										<view class="c2 bootm">{{item.community}}</view>
										<view class="c3 bootm">场所编码:{{item.placeCode}}</view>
										<view class="c4 bootm">{{item.address}}</view>
										<view class="c5">评分：{{item.score}}分</view>
									</view>
									<view class="loadingType">{{loadingType == true ?'没有更多数据了!' : '上拉显示更多'}}</view>
								</uni-forms>
							</scroll-view>

						</view>
					</view>

				</view>
			</uni-popup>
		</scroll-view>

	</view>
</template>

<script>
	import searchinput from '../component/searchinput.vue'
	import analysisdrawer from '../component/analysisdrawer.vue'
	import server from '@/api/server.js'
	export default {

		name: 'gateway',
		props: {
			cur: String,
		},
		watch: {

		},
		data() {
			return {
				typelei: 3,
				modalName: null,
				searchDesc: '',
				dangerDesc: '',
				formDataList: [],
				dangerList: [],
				formData: {
					checkStartTime: '',
				},
				loadingType:false,
				onReachobj: {
					dimension: '',
					id: '',
					placeName: '',
					status: '',
					pageNo: 1,
					pageSize: 10,
				}
			}
		},
		mounted() {
			this.$refs.mainindex.formData.dimension = 'criteria'
			this.$refs.mainindex.formData.placeType = '3'
			this.$refs.mainindex.formSubmit()
		},
		methods: {
			// 跳转
			gotoDetail(dangerId, placeId) {
				uni.navigateTo({
					// ? 后面加要传的参数， 多个参数用 & 隔开 
					url: '/pages/siteinvestigation/dangerdetail?id=' +  dangerId + '&placeId=' + placeId
				})
			},
			lowerBottom() {
				console.log(1111)
				this.scrolldanger();
			},
			//隐患清单
			compCheck(id, status) {
				this.dangerList = []
				this.onReachobj.pageNo = 1
				console.log(id)
				console.log(status)
				this.onReachobj.id = id
				this.onReachobj.status = status
				this.onReachobj.dimension = this.$refs.mainindex.formData.dimension
				this.onReachobj.placeName = this.searchDesc,
				this.$refs.bottompopup.open('top')
				this.scrolldanger()

			},
			scrolldanger() {
				server.dangerlist(this.onReachobj).then(res => {
					console.log(res)
					if (res.data.result.records.length == 0) { //没有数据
						console.log('1111111111111111111111111111111111111')
						this.loadingType = true;
						return;
					}

					this.onReachobj.pageNo++; //每触底一次 page +1					
					this.dangerList = this.dangerList.concat(res.data.result.records); //将数据拼接在一起
				})
			},
			//
			compclose() {
				this.$refs.bottompopup.close()
			},
			getlist(e) {
				server.queryDanger(e).then(res => {
					console.log(res)
					this.formDataList = res.data.result
					this.$refs.mainindex.closeDrawer()
				})
			}
		},
		components: {
			searchinput,
			analysisdrawer
		}
	}
</script>

<style scoped lang="scss">
	.disflex {
		display: flex;
		justify-content: space-between;

		.span {
			width: 20%;
			display: flex;
			align-items: center;
			justify-content: center;
			background: white;
		}
	}

	// 时间
	.uni-btn-v {
		display: flex;
		margin-top: 20px;
		position: fixed;
		bottom: 0;
		width: 100%;

		uni-button {
			width: 100%;
			border-radius: 30px;
			margin: 10px;
		}

		uni-button:after {
			border: unset;
		}
	}

	.scrollHeight {
		height: 400px;
	}
	.box .formbox .ul .c5{
		position: absolute;
		    bottom: 0;
		    right: 0;
	}
	.box .formbox .ul{
		display: unset!important;
		float: left;
		width: 100%;
	}
</style>
